package com.wjw.springsecuritydemo.controller;

import org.springframework.security.access.annotation.Secured;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

@Controller
public class LoginController {
//    @RequestMapping("login")
//    public String login(){
//        System.out.println("login....");
//        return "redirect:main.html";
//    }
//    @RequestMapping("main")
//    public String main(){
//        System.out.println("进入main controller");
//        return "main.html";
//    }
    //PreAuthorize的表达式可以加ROLE_开头也可以不加，配置类不能加
    @Secured("ROLE_gm")
    //@PreAuthorize("hasRole('gm')")
    @RequestMapping("toMain")
    public String toMain(){

        return "redirect:main.html";
        //return "main2";
    }
    @RequestMapping("toError")
    public String toError(){

        return "redirect:error.html";
    }
    @RequestMapping("main2")
    public String main2(){

        return "main2";
    }

    @RequestMapping("alogin")
    public String alogin(){

        return "alogin";
    }

    @RequestMapping("showlogin")
    public String showlogin(){

        return "alogin";
    }
}
